/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package service.impl;

import eao.EaoLocal;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import model.entity.Customer;
import model.entity.Role;
import model.entity.User;
import service.IUserService;
import service.InterfaceServiceLocal;

/**
 *
 * @author dingnangen
 */
@Stateless

public class UserManager extends AbstractService<User> implements IUserService<User> {

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @EJB(beanName = "UserFacade")
    eao.EaoLocal<User> userFacade;

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @Override
    protected EaoLocal getEao() {
        return userFacade;
    }

    //@Override
    public List findRoleByUserLoginName(String loginName) {
        List<String> list = new ArrayList();
        list.add(loginName);
        List findAll = userFacade.findAll("select r from Role r where r.userList in(select u from User u where u.loginname=?1)", list);
        list.clear();
        System.out.println("UserManager"+findAll.size());findAll.size();
        for (Object r : findAll) {
            list.add(((Role) r).getRoleid());
        }
        return list;
    }
}
